
const requireComponent = require.context(
    // 组件目录的相对路径
    "../components",
    // 是否查询子目录
    true,
    // 匹配基础组件文件名的正则表达式
    // /v[a-z]\w+\.(vue|js)$/
    /\.(vue)$/,
    // 配置是否异步加载
    "sync"
);
console.log(requireComponent, "组件的注册"); // require.context  返回的是一个函数
console.log(requireComponent.keys());
let module = {};
const GlobalComponents = (app) => {
    requireComponent.keys().forEach((fileName) => {
        // 获取组件配置
        const componentConfig = requireComponent(fileName);
        const key = fileName.split("/").at(1);
        console.log(componentConfig.default);
        console.log(key, "key的值")
        console.log(componentConfig.default, "default的值")
        const component = requireComponent(fileName).default;

        // module[key] = requireComponent(fileName).default;
        app.component(`${componentConfig.default.name}`, component)
    });
}

export default GlobalComponents

